package com.shd.day04;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author S5343
 * @date 2018年7月23日下午8:38:51
 */
public class StreamFilter {

	public static void main(String[] args) {
		List<Integer> arr = Arrays.asList(1, 2, 3, 4, 5, 6, 6, 7, 7, 7);
		List<Integer> list = arr.stream().filter(i -> i % 2 == 0).collect(Collectors.toList());
		System.out.println(list); // [2, 4, 6, 6]

		List<Integer> collect = arr.stream().distinct().collect(Collectors.toList());
		System.out.println(collect); // [1, 2, 3, 4, 5, 6, 7]

		List<Integer> collect2 = arr.stream().skip(5).collect(Collectors.toList());
		System.out.println(collect2); // [6, 6, 7, 7, 7]

		List<Integer> collect3 = arr.stream().limit(5).collect(Collectors.toList());
		System.out.println(collect3); // [1, 2, 3, 4, 5]
	}
}
